package static_;

public class StaticExercise01 {
    public static void main(String[] args) {
        Person.setTotalPerson(3);
        new Person();
        Person.showTotal();
    }
}
//静态方法只能访问静态成员；非静态方法可以访问所有的
//编写代码时，要遵守访问权限
class Person {
    private int id;
    private static int total = 0;

    public static void setTotalPerson(int total) {
        Person.total = total;
    }

    public Person() {
        total++;
        id = total;
    }

    public static int getTotal() {
        return Person.total;
    }

    //编写一个方法，输出total的值
    public static void showTotal() {
        System.out.println(total);
    }
}
